/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nus.dataaccess.dao.role.dao;

import com.nus.dataaccess.dao.base.dao.BaseDao;
import com.nus.dataaccess.dao.role.RoleType;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

/**
 *
 * @author kenny
 */
public class RoleTypeDao extends BaseDao<RoleType>{

    private static RoleTypeDao instance;

    public static RoleTypeDao getInstance() {
        if (null == instance) {
            instance = new RoleTypeDao();
        }
        return instance;
    }
    private RoleTypeDao(){}

    @Override
    protected Class getReferenceClass() {return RoleType.class;}

    public RoleType getByRoleTypeId(Long id){
       Criteria crit = super.createCriteria();
       crit.add(Restrictions.eq("id", id));
       crit.setMaxResults(1);
       List<RoleType> roleTypes = crit.list();
       return (roleTypes!=null && !roleTypes.isEmpty()) ? roleTypes.get(0) : null;
    }

}
